﻿<navigation:Page x:Class="Corina.Lantern.Hub.Views.Register"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
                 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                 xmlns:localViewmodel="clr-namespace:Corina.Lantern.Hub.Viewmodels"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                 Style="{StaticResource PageStyle}"
                 d:DesignHeight="480"
                 d:DesignWidth="900"
                 mc:Ignorable="d">
    <navigation:Page.DataContext>
        <localViewmodel:RegisterViewmodel />
    </navigation:Page.DataContext>


    <navigation:Page.Resources>
        <Style x:Key="style_labeltext" TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Foreground" Value="{StaticResource NormalFontBrush}" />
        </Style>

        <Style x:Key="style_desc" TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="TextWrapping" Value="NoWrap" />
            <Setter Property="Foreground" Value="{StaticResource COLOR_LIGHTDARK}" />
            <Setter Property="Margin" Value="6,0,0,0" />
        </Style>

        <ControlTemplate x:Key="style_listboxitem1" TargetType="ListBoxItem">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="24" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Path Width="18"
                      Height="18"
                      Margin="0,0,0,0"
                      Data="{Binding Converter={StaticResource StringToPathGeometryConverter},
                                     Source={StaticResource ICON_CHECK}}"
                      Fill="{StaticResource NormalFontBrush}"
                      RenderTransformOrigin="0.5,0.5"
                      Stretch="Uniform"
                      Visibility="{Binding IsSelected,
                                           Converter={StaticResource BooleanToVisibilityConverter},
                                           RelativeSource={RelativeSource TemplatedParent}}">
                    <Path.RenderTransform>
                        <TransformGroup>
                            <TransformGroup.Children>
                                <RotateTransform Angle="0" />
                                <ScaleTransform ScaleX="1" ScaleY="1" />
                            </TransformGroup.Children>
                        </TransformGroup>
                    </Path.RenderTransform>
                </Path>

                <ContentControl Grid.Column="1"
                                VerticalAlignment="Center"
                                Content="{Binding Title}" />
            </Grid>
        </ControlTemplate>

        <Style x:Key="style_listboxitem_withradiobox" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <RadioButton Margin="0,0,6,0"
                                     Content="{Binding Title}"
                                     IsChecked="{Binding IsSelected,
                                                         Mode=TwoWay,
                                                         RelativeSource={RelativeSource TemplatedParent}}" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot">
        <toolkit:BusyIndicator BusyContent="正在提交注册信息，请稍等..." IsBusy="{Binding IsBusy}">
            <ScrollViewer BorderBrush="Transparent"
                          BorderThickness="0"
                          ScrollViewer.HorizontalScrollBarVisibility="Auto"
                          VerticalScrollBarVisibility="Hidden">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="300" />
                    </Grid.ColumnDefinitions>
                    <StackPanel>
                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="帐号：" />
                                <Run Foreground="Red" Text="*" />
                            </TextBlock>
                            <TextBox Grid.Column="1" Text="{Binding UpdateEntity.Account, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <ei:CallMethodAction MethodName="TextChanged" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="LostFocus">
                                        <ei:CallMethodAction MethodName="LostFocus" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </TextBox>
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="密码：" />
                                <Run Foreground="Red" Text="*" />
                            </TextBlock>
                            <PasswordBox Grid.Column="1" Password="{Binding UpdateEntity.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="PasswordChanged">
                                        <ei:CallMethodAction MethodName="PasswordChanged" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="LostFocus">
                                        <ei:CallMethodAction MethodName="LostFocus" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </PasswordBox>
                            <TextBlock Grid.Column="2"
                                       Style="{StaticResource style_desc}"
                                       Text="密码不得少于6位" />
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="确认密码：" />
                                <Run Foreground="Red" Text="*" />
                            </TextBlock>
                            <PasswordBox Grid.Column="1" Password="{Binding ConfirmPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="PasswordChanged">
                                        <ei:CallMethodAction MethodName="PasswordChanged" TargetObject="{Binding}" />
                                    </i:EventTrigger>

                                    <i:EventTrigger EventName="LostFocus">
                                        <ei:CallMethodAction MethodName="LostFocus" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </PasswordBox>
                            <TextBlock Grid.Column="2"
                                       Foreground="Red"
                                       Style="{StaticResource style_desc}"
                                       Text="两次输入的密码不一致！"
                                       Visibility="{Binding PasswordNotMatched,
                                                            Converter={StaticResource BooleanToVisibilityConverter}}" />
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="名称：" />
                                <Run Foreground="Red" Text="*" />
                            </TextBlock>
                            <TextBox Grid.Column="1" Text="{Binding UpdateEntity.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <ei:CallMethodAction MethodName="TextChanged" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </TextBox>
                            <TextBlock Grid.Column="2"
                                       Style="{StaticResource style_desc}"
                                       Text="个人填写姓名，其他填写单位名称。" />
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="电话：" />
                            </TextBlock>
                            <TextBox Grid.Column="1" Text="{Binding UpdateEntity.Mobile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <ei:CallMethodAction MethodName="TextChanged" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </TextBox>
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="电子邮件：" />
                            </TextBlock>
                            <TextBox Grid.Column="1" Text="{Binding UpdateEntity.Email, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <ei:CallMethodAction MethodName="TextChanged" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </TextBox>
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="联系人：" />
                            </TextBlock>
                            <TextBox Grid.Column="1" Text="{Binding UpdateEntity.Linkman, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <ei:CallMethodAction MethodName="TextChanged" TargetObject="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </TextBox>
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="帐号类型：" />
                                <Run Foreground="Red" Text="*" />
                            </TextBlock>
                            <ListBox Grid.Column="1"
                                     ItemContainerStyle="{StaticResource style_listboxitem_withradiobox}"
                                     ItemsSource="{Binding UserKindCollection}"
                                     ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                     SelectedItem="{Binding SelectedUserKind,
                                                            Mode=TwoWay}"
                                     Style="{StaticResource NoframeListboxStyle}">
                                <ListBox.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <toolkit:WrapPanel Orientation="Horizontal" />
                                    </ItemsPanelTemplate>
                                </ListBox.ItemsPanel>
                            </ListBox>
                            <TextBlock Grid.Column="2"
                                       Style="{StaticResource style_desc}"
                                       Text="" />
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource style_labeltext}">
                                <Run Text="所属行业：" />
                                <Run Foreground="Red" Text="" />
                            </TextBlock>
                            <ComboBox Grid.Column="1"
                                      ItemsSource="{Binding IndustryCollection}"
                                      SelectedItem="{Binding SelectedIndustry,
                                                             Mode=TwoWay}">
                                <ComboBox.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <VirtualizingStackPanel />
                                    </ItemsPanelTemplate>
                                </ComboBox.ItemsPanel>
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Title}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                            <TextBlock Grid.Column="2"
                                       Style="{StaticResource style_desc}"
                                       Text="" />
                        </Grid>

                        <Rectangle Margin="0,6" Style="{StaticResource BreakLineStyle}" />

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <CheckBox Grid.Column="1"
                                      Grid.ColumnSpan="2"
                                      Content="我同意右侧所述各条款，并愿意承担因违反条款带来的后果。"
                                      IsChecked="{Binding AgreePolicy,
                                                          Mode=TwoWay,
                                                          UpdateSourceTrigger=PropertyChanged}" />
                        </Grid>

                        <Grid Margin="0,6">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120" />
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <StackPanel Grid.Column="1"
                                        HorizontalAlignment="Right"
                                        Orientation="Horizontal">
                                <HyperlinkButton Margin="12,0"
                                                 VerticalAlignment="Center"
                                                 Command="{Binding GotoLoginCommand}"
                                                 Content="返回登录" />
                                <Button Command="{Binding SubmitCommand}" Content="提交注册信息" />
                            </StackPanel>
                        </Grid>

                    </StackPanel>

                    <Grid Grid.Column="1" Margin="12,0,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock Style="{StaticResource Heading3}" Text="注册条款" />

                        <ScrollViewer Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Hidden" />
                    </Grid>
                </Grid>
            </ScrollViewer>
        </toolkit:BusyIndicator>

    </Grid>
</navigation:Page>
